package client.comm.baoding.adapter

import android.content.Context
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.comm.commlib.base.BaseLoadmoreAdapter
import client.comm.commlib.base.BindingViewHoder
import client.comm.baoding.R
import client.comm.baoding.api.bean.TuikuanList
import client.comm.baoding.databinding.LayoutTuikuanlistitemBinding

import com.bumptech.glide.RequestManager

class TuikuanlistAdapter : BaseLoadmoreAdapter<TuikuanList.Order> {

    val manager: RequestManager

    constructor(context: Context, manager: RequestManager) : super(context) {
        this.manager = manager
    }

    override fun createVh(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {

        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.layout_tuikuanlistitem,
                parent,
                false
            )
        )
    }

    override fun bindVh(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val binding = bindingViewHolder.binding as LayoutTuikuanlistitemBinding
        val b = getItem(position)
        binding.bean = b
        manager.load(b.goods_img).into(binding.img)

        when (b.status) {
            1 -> {
                binding.status = "审核中"
            }
            2 -> {
                binding.status = "成功"
            }
            3 -> {
                binding.status = "失败"
            }
        }
    }
}